package com.hengxinguotong.zhihuichengjian.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.hengxinguotong.zhihuichengjian.R;
import com.hengxinguotong.zhihuichengjian.widget.font.HXTextView;
import com.orhanobut.logger.Logger;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by liux on 15/9/10.
 */
public class SelectListAdapter extends BaseAdapter {
    private ViewHolder holder;
    private String TAG = "SelectListAdapter";
    private Context mContext;
    private String[] strings;

    public SelectListAdapter(Context context, String[] strings) {
        mContext = context;
        this.strings = strings;
    }

    @Override
    public int getCount() {
        return strings.length;
    }

    @Override
    public Object getItem(int position) {
        return strings[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null || convertView.getTag() == null) {
            convertView = LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.item_dialog_select_list, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        Logger.d("strings[position]------"+strings[position]);
        holder.itemSelectlistName.setText(strings[position]);
        return convertView;
    }

    static class ViewHolder {
        @BindView(R.id.item_selectlist_name)
        HXTextView itemSelectlistName;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
